# @arthor quoc.le
package Juniper;
sub new
{
    my $class = shift;
    my $self = {
        _fileName => shift,
        _variable => shift,
        _paramsDefault =>shift,
        _testCase  => shift,
        _topology  => shift,
        _routerConfig  => shift
    };

    bless $self, $class;
    return $self;
}
# Getter & Setter

# File Name
sub setFileName {
    my ( $self, $fileName ) = @_;
    $self->{_fileName} = $fileName if defined($fileName);
    return $self->{_fileName};
}

sub getFileName {
    my( $self ) = @_;
    return $self->{_fileName};
}

# Variable
sub setVariable {
    my ( $self, $variable ) = @_;
    $self->{_variable} = $variable if defined($variable);
    return $self->{_variable};
}

sub getVariable {
    my( $self ) = @_;
    # return $self->{_variable};
    # quoc.le
    my %values; # Hold all values
    my $val = $self->{_variable};
    my @vals = split(';',$val);
    for my $item (@vals)
    {
        # print $item;
        if($item =~ m/\"/)
        { 
             my @items = split('\"',$item);
             # print $items[0]," ", $items[1];
             my @its = split(' ',$items[0]);
             $values{$ite[0]} = $items[1];
             print "\nvalues1 ",$its[0]," ",$items[1],"\n";
        }else
        {
            my @items2 = split(/\s+/,$item);
            $values{$items2[0]} = $items2[1];
            print "\nvalues2 ",$items2[1]," ",$items2[2],"\n";
        }
    }
    return %values;
}
# Param Default
sub setParamsDefault {
    my ( $self, $paramsDefault ) = @_;
    $self->{_paramsDefault} = $paramsDefault if defined($paramsDefault);
    return $self->{_paramsDefault};
}

sub getParamsDefault {
    my( $self ) = @_;
    return $self->{_paramsDefault};
}
# TestCase
sub setTestCase {
    my ( $self, $testCase ) = @_;
    $self->{_testCase} = $testCase if defined($testCase);
    return $self->{_testCase};
}

sub getTestCase {
    my( $self ) = @_;
    return $self->{_testCase};
}

# Topology
sub setTopology {
    my ( $self, $topology ) = @_;
    $self->_topology = $topology if defined($topology);
    return $self->{_topology};
}

sub getTopology {
    my( $self ) = @_;
    return $self->{_topology};
}

# Router Config
sub setRouterConfig {
    my ( $self, $routerConfig ) = @_;
    $self->{_routerConfig} = $routerConfig if defined($routerConfig);
    return $self->_routerConfig;
}

sub getRouterConfig {
    my( $self ) = @_;
    return $self->{_routerConfig};
}

# Show all data
sub showAll
{
    my( $self ) = @_;
    print $self->{_fileName}, "\n";
    print $self->{_variable},"\n";
    print $self->{_testCase},"\n";
    print $self->{_topology},"\n";
    print $self->{_routerConfig},"\n";

}
sub addQuotes() { 
    my $string = shift;
    return "\"" + $string + "\""; 
} 
1;